﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Web.Security;

namespace CarBlackBox
{
    public partial class Form_ChangePassword : Form
    {
        public Form_ChangePassword()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text) || string.IsNullOrEmpty(textBox3.Text))
            {
                MessageBox.Show("三个文本框均不可为空");
                return;
            }
            if (!string.Equals(textBox2.Text, textBox3.Text))
            {
                MessageBox.Show("两次输入密码应该一样");
                textBox2.Text = "";
                textBox3.Text = "";
                textBox2.Focus();
                return;
            }
            try
            {
                MembershipUser user = Membership.GetUser(Form_Main.Operator);
                user.ChangePassword(textBox1.Text, textBox2.Text);
                MessageBox.Show("密码更改成功");
                this.Close();
            }
            catch (MembershipCreateUserException ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            WFNetLib.Log.SystemLogData log = new WFNetLib.Log.SystemLogData();
            log.LogType = LogType.系统设置.ToString();
            log.LogContent = "更改密码";
            log.LogRemark = "系统设置";
            log.InserSQLLog();
        }
    }
}
